package com.mlnx.work.pojo.vo;

import com.mlnx.work.enums.ProjectStatusEnum;
import com.mlnx.work.utils.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @Author: Akrio
 * @Date: 2021-01-20 9:18
 */
@Data
@ApiModel("项目进度类")
public class ProjectScheduleStatisticsVO {
    @ApiModelProperty("项目ID")
    private Integer dirId;
    @ApiModelProperty("项目名称")
    private String dirName;
    @ApiModelProperty("开始时间")
    private Long startTime;
    @ApiModelProperty("结束时间")
    private Long completedTime;
    @ApiModelProperty("负责人")
    private String name;
    @ApiModelProperty("最初计划结束时间")
    private Long originEndTime;
    @ApiModelProperty("风险项")
    private String risk;
    @ApiModelProperty("项目状态")
    private ProjectStatusEnum status;
    @ApiModelProperty("待完成")
    private Integer unFinished;
    @ApiModelProperty("延期任务")
    private Integer delayTask;
    @ApiModelProperty("已完成")
    private Integer finished;
    @ApiModelProperty("项目进度")
    private String projectSchedule;

    public String getStatus() {
        if (ProjectStatusEnum.ING.equals(status))
            if (DateUtil.dateCompare(originEndTime, System.currentTimeMillis()) < 0)
                status = ProjectStatusEnum.OVERDUE;
            else if (!risk.trim().isEmpty())
                status = ProjectStatusEnum.RISK;

        return status.getStatus();
    }
}
